const vm = new Vue({
    el: '#main',
    data: {
        selectedHouse: '',
        houseList: [],
        house: {},
    },
    methods: {
        select,
    },
});

function apiready() {
    fxj.fixLayout();
    reqHouseList();
}

async function reqHouseList() {
    vm.selectedHouse = '';
    vm.house = {};
    const res = await ajax({
        url: 'home/CleaningService/getCleaningAddress',
    });
    if (res.data) {
        res.data.forEach(house => {
            house.img = fxj.fixImgUrl(house.img);
        });
        vm.houseList = res.data;
    }
}

function select(house) {
    vm.selectedHouse = house.aid;
    vm.house = house;
}

function next() {
    if (!vm.selectedHouse) {
        toast('请选择需要保洁的房源');
        return;
    }
    goPage('clean_keep_info.html', {
        data: {
            aid: vm.selectedHouse,
            address: encodeURIComponent(vm.house.address_detail),
            title: encodeURIComponent(vm.house.title),
            img: encodeURIComponent(vm.house.img),
        },
    });
}